Ext.define('Emp.view.district.Edit', {
	extend: 'Emp.view.BaseEdit',
	alias: 'widget.districtedit',
	
	requires: [
		'Emp.ux.form.field.ComboTree',
		'Emp.store.Status',
		'Emp.ux.form.field.ComboBoxStatus',
		'Emp.store.DictionaryQuery'
	],

	width: 300,
	height: 280,
	
	initComponent: function() {
		var me = this;
		
		me.items = [{
			xtype: 'form',
			border: false,
			bodyPadding: 5,
			layout: 'anchor',
			defaults: {
				labelAlign: 'right',
				labelWidth: 60,
				anchor: '95%'
			},
			defaultType: 'textfield',
			items: [{
					fieldLabel: 'id',
					name: 'id',
					hidden: true
				}, {
					fieldLabel: '代码',
					name: 'code',
					allowBlank: false
				}, {
					fieldLabel: '名称',
					name: 'name',
					allowBlank: false
				}, {
					fieldLabel: '上级',
					name: 'parentId',
					xtype: 'combotree',
					forceSelection:true,
					treeConfig: {
						useArrows: true,
						rootVisible: true,
						hideHeaders: true,
						columns: [{
							xtype: 'treecolumn',
							text: 'name',
							dataIndex: 'name',
							renderer: function(value, metaData, record) {
								return value + '(' + record.get('code') + ')';
							},
							flex: 1
						}]
					},
					displayField: 'name',
					valueField: 'id',
					store: Ext.create('Emp.store.DistrictNode')
//				}, {
//					fieldLabel: '等级',
//		            name: 'level',
//		            xtype: 'comboboxstatus',
//					store: Ext.create('Ext.data.Store', {
//					    fields: ['display', 'value', 'status'],
//					    data: Emp.getDictionarys('district_level')
//					}),
//					queryMode: 'local',
//					displayField: 'display',
//					valueField: 'value',
//					forceSelection: true,
//					allowBlank: false
					}, {
					fieldLabel: '等级',
		            name: 'level',
		            xtype: 'comboboxstatus',
					store: Ext.create('Ext.data.Store', {
						model: 'Emp.model.Dictionary',
						autoLoad: true,
						proxy: {
							type: 'ajax',
							url: PATH + '/dictionary/query',
							extraParams: {
								code: 'district_level'
							},
							reader: {
								type: 'json',
								root: 'datas',
								totalProperty: 'totalCount'
							}
						}
					}),
					queryMode: 'local',
					displayField: 'display',
					valueField: 'value',
					forceSelection: true,
					allowBlank: false
				}, {
		            fieldLabel: '状态',
		            name: 'status',
		            xtype: 'combobox',
					store: Ext.create('Emp.store.Status'),
					queryMode: 'local',
					displayField: 'display',
					valueField: 'value',
					forceSelection: true,
					allowBlank: false
				}, {
					fieldLabel: '排序',
					name: 'sort',
					xtype: 'numberfield',
					hideTrigger: true,
					allowDecimals:false,
					allowBlank: false
			}]
		}];
		me.callParent();
	}
});